<template>
    <rx-dialog @handOk="handleSubmit" @cancel="cancel">
        <div style="padding: 10px;box-sizing: border-box;height: 100%;">
            <div style="height: 100%;">
                <rx-monaco-editor
                    v-model="val"
                    language="json"
                >
                </rx-monaco-editor>
            </div>
        </div>
    </rx-dialog>
</template>

<script>
    import {RxDialog,Util,RxMonacoEditor} from "@lowcode/jpaas-common-lib";

    export default {
        name: "SysInterfaceApiImportJson",
        components: {
            RxDialog,
            RxMonacoEditor
        },
        props: {
            layerid: {
                type: String,
                default: ""
            },
            script: {
                type: String,
                default: ""
            },
            destroy: {
                type: Function
            }
        },
        data() {
            return {
                val:this.script
            }
        },
        methods: {
            i18n(name,text,key){
                return this.$ti18(name,text,"sysInterfaceProject",key);
            },
            handleSubmit(vm) {
                try {
                    Util.closeWindow(this,"ok",JSON.parse(this.getScripts()))
                }catch (e) {
                    vm.loading=false;
                    this.$message.error(this.i18n('apiEdit.jsonFormatError','json 数据格式有误'));
                }
            },
            cancel() {
                Util.closeWindow(this,"cancel")
            },
            getScripts(){
                return this.val;
            }
        }
    }
</script>

<style scoped>

</style>